package main

import (
	"fmt"
)

/*
	面向对象 --》 struct

	type struct_name struct {
		field1 type
		field2 type
		...
	}
*/

type cat struct {
	name  string
	age   byte
	color string
}

func main() {

	// write method 1
	var c cat
	c.name = "jack"
	c.age = 18
	c.color = "green"
	fmt.Println(c)

	// write method 2
	var c2 cat = cat{"marry", 18, "red"}
	fmt.Println(c2)

	c3 := cat{"chenji", 20, "white"}
	fmt.Println(c3)

	// return struct ptr

	// write mthod 3
	// (*ptr).field == ptr.field 底层做优化，对指针进行取值运算
	c4 := new(cat)
	(*c4).name = "xie"
	(*c4).age = 21
	(*c4).color = "blue"
	fmt.Println(*c4)

	c4.name = "xile"
	fmt.Println(*c4)

	// c5 := &cat{"lelel", 22, "black"}
	c5 := &cat{}
	c5.name = "lele"
	c5.age = 22
	c5.color = "black"
	fmt.Println(*c5)

}
